//
//  ContentTableViewCell.m
//  xhtios1.0
//
//  Created by hlt on 15/4/29.
//  Copyright (c) 2015年 hlt. All rights reserved.
//

#import "ContentTableViewCell.h"
#import "HLTShopViewController.h"
@implementation ContentTableViewCell



- (void)awakeFromNib {
    // Initialization code
    _biaozhi=YES;
    _shopcontentweb.delegate=self;
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}




- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    
    NSString *str=[NSString stringWithFormat:@"maxwidth=%f;",screen_width];
    
    NSString *sss=@"var script =document.createElement('script');"
    "script.type = 'text/javascript';"
    "script.text = \"function ResizeImages(){ "
    "var myimg,oldwidth,oldheight;"
    "var maxwidth=320;"
    "for(i=0;i<document.images.length;i++){"
    "myimg = document.images[i];"
    "if(myimg.width > maxwidth){"
    "myimg.width = maxwidth;"
    "}"
    "}"
    "}\";"
    "document.getElementsByTagName('head')[0].appendChild(script);";
    
    
    
    NSString *ss1=[sss  stringByReplacingOccurrencesOfString:@"maxwidth=320;" withString:str];
    
    [webView stringByEvaluatingJavaScriptFromString:
     
     ss1];
    
    [webView stringByEvaluatingJavaScriptFromString:@"ResizeImages();"];
    
    
    
    
    //字体大小
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '100%'"];
    //字体颜色
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'black'"];
    //页面背景色
//    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='#0C78C6'"];
    
   
    //NSInteger htmlHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"];
    
    //获取到webview当前的html，如果没有说明是初始化的那一次加载
//    NSString *lHtml1 = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.innerHTML"];
//    
//    if (lHtml1) {
    if (_biaozhi) {
        
        
        
        
    
    CGRect frame = webView.frame;
    frame.size.height = 1;
    webView.frame = frame;
    
    CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
//        NSInteger ssa=fittingSize.height;
        fittingSize.height=fittingSize.height+5;
    _parent.height=fittingSize.height;
    frame.size = fittingSize;
    webView.frame = frame;
    //刷新指定的section,显示优惠商户的部分
//        [_parent.rmdTableView reloadData];
        
        
        //如果用针对性的刷新
    NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];
    [_parent.rmdTableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
    
        _biaozhi=NO;
    }
    
    
    
}


@end
